$OpenBSD: patch-plugins_gtkui_ddblistview_c,v 1.2 2014/09/23 15:03:39 dcoppa Exp $

commit 05f3d65bb98cb7f7756ea6ff2632f7fcda7c9fbb
Author: Alexey Yakovenko <waker@users.sourceforge.net>
Date:   Fri Sep 12 21:24:16 2014 +0200

gtkui: fix random crash after closing playlist using menu (bug #1193)

--- plugins/gtkui/ddblistview.c.orig	Thu Jul 31 21:16:23 2014
+++ plugins/gtkui/ddblistview.c	Tue Sep 23 16:28:20 2014
@@ -33,6 +33,7 @@
 #include "gtkui.h"
 #include "support.h"
 #include "actionhandlers.h"
+#include "callbacks.h"
 
 #define min(x,y) ((x)<(y)?(x):(y))
 #define max(x,y) ((x)>(y)?(x):(y))
@@ -329,6 +330,7 @@ ddb_listview_init(DdbListview *listview)
     listview->columns = NULL;
     listview->lock_columns = 1;
     listview->groups = NULL;
+    listview->plt = NULL;
 
     listview->block_redraw_on_scroll = 0;
     listview->calculated_grouptitle_height = DEFAULT_GROUP_TITLE_HEIGHT;
@@ -3206,6 +3208,10 @@ ddb_listview_free_groups (DdbListview *listview) {
         free (listview->groups);
         listview->groups = next;
     }
+    if (listview->plt) {
+        deadbeef->plt_unref (listview->plt);
+        listview->plt = NULL;
+    }
 }
 
 void
@@ -3214,6 +3220,9 @@ ddb_listview_build_groups (DdbListview *listview) {
     int old_height = listview->fullheight;
     listview->groups_build_idx = listview->binding->modification_idx ();
     ddb_listview_free_groups (listview);
+
+    listview->plt = deadbeef->plt_get_curr ();
+
     listview->fullheight = 0;
 
     DdbListviewGroup *grp = NULL;
